<!doctype html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>{:getConfig('site.site_name')}</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/login.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script type="text/javascript" src="/static/js/jquery.min.3.2.1.js"></script>
    <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script src="/static/js/crypto-js.js" charset="utf-8"></script>
    <!--[if lt IE 9]>
    <script src="/static/js/html5.min.js"></script>
    <script src="/static/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="login-bg">
{if !empty(getConfig('site.template1.login_left_logo'))}
<img class="loging-left-top" src="{:getConfig('site.template1.login_left_logo')}">
{/if}
<div class="login layui-anim layui-anim-up">
    <div>
        <div class="login_user">
            <div class="login_left" style="background-image: url({:getConfig('site.template1.login_center_logo')})">
            </div>
            <span class="login_text">{:getConfig('site.site_name')}后台系统</span>
            <form method="post" class="login_input">
                <input type="text" id="username" name="username" placeholder="用户名" autocomplete="off" class="layui-input">
                <hr class="hr15">
                <input name="password" id="password" placeholder="密码" type="password" class="layui-input">
                <hr class="hr15">
                <input style="height: 40px;margin-top: 10px;line-height: 20px;" value="登录" lay-submit
                       lay-filter="login" style="width:100%;" type="submit">
                <hr class="hr20">
            </form>
            <span class="login-text_1"></span>
            <div class="login-bottom">
                <div style="margin-bottom: 0.4rem;">——{:getConfig('site.site_name')}·系统管理后台——</div>
                <div>{:getConfig('site.site_icp_no')}</div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'layer'],
        function() {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

            //监听提交
            form.on('submit(login)',
                function(data) {
                    var us = $('#username').val();
                    var ps = $('#password').val();

                    if(us.length == 0)
                    {
                        layer.msg('请输入用户名', {
                            icon: 5
                            ,anim: 6
                        });
                        return false;
                    }

                    if(us.length < 3)
                    {
                        layer.msg('用户名必须大于3个字符', {
                            icon: 5
                            ,anim: 6
                        });
                        return false;
                    }

                    if(ps.length == 0)
                    {
                        layer.msg('请输入密码', {
                            icon: 5
                            ,anim: 6
                        });
                        return false;
                    }

                    if(ps.length  < 6 || ps.length > 12)
                    {
                        layer.msg('密码必须是6-12个字符', {
                            icon: 5
                            ,anim: 6
                        });
                        return false;
                    }

                    $.ajax({
                        url: '../Login/login',
                        dataType: 'json',
                        data: {username:us,password:CryptoJS.SHA1(ps).toString(CryptoJS.enc.Base64),status:1},
                        type: 'post',
                        success:function(data){
                            if(data.code == 200)
                            {
                                layer.msg(data.msg, {
                                    icon: 6
                                    ,anim: 0
                                },function() {
                                    location.href = '/Index/index';
                            });
                            }else {
                                layer.msg(data.msg, {
                                    icon: 5
                                    ,anim: 6
                                });
                            }
                        }
                    })
                    return false;
                });
        });
</script>
<!-- 底部结束 -->
</body>
</html>
